package com.meiyu.live.tv.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.SeekBar;

import com.meiyu.live.R;

/**
 * Created by zbl on 2016/12/9.
 * 美颜效果设置view
 */
public class BeautySettingView extends FrameLayout implements View.OnClickListener {

    public interface OnBeautySettingChangeListener {
        void onBlurSizeChange(int progress);
    }

    private Context context;

    private OnBeautySettingChangeListener listener;

    private SeekBar seekbar;

    public BeautySettingView(Context context) {
        super(context);
        init(context);
    }

    public BeautySettingView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    private void init(Context context) {
        this.context = context;
        LayoutInflater.from(context).inflate(R.layout.view_beauty_setting, this);
        seekbar = (SeekBar) findViewById(R.id.seekbar);
        seekbar.setProgress(1);
        seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                if (listener != null) {
                    listener.onBlurSizeChange(progress);
                }
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {

            }
        });
    }

    @Override
    public void onClick(View view) {

    }

    public void setValue(int value) {
        seekbar.setProgress(value);
    }

    public void setListener(OnBeautySettingChangeListener listener) {
        this.listener = listener;
    }
}
